﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace YJTMedicalAideManage.Cores.Events
{
    public class LoginVisibilityEvent
    {
        private static LoginVisibilityEvent _instance;

        // 私有构造函数，防止外部直接实例化
        private LoginVisibilityEvent() { }

        public static LoginVisibilityEvent Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new LoginVisibilityEvent();
                }
                return _instance;
            }
        }
        public delegate void VisibilityEventHandler(Visibility v);

        public event VisibilityEventHandler OnMessageReceived;

        public void PushMessage(Visibility message)
        {
            OnMessageReceived?.Invoke(message); // 触发事件
        }
        public void Subscribe(VisibilityEventHandler handler)
        {
            OnMessageReceived += handler;
        }

        public void Unsubscribe(VisibilityEventHandler handler)
        {
            OnMessageReceived -= handler;
        }
    }
}
